js下拉框去掉重复的

您所在的位置:网站首页 android 下拉框过滤掉重复的值 js下拉框去掉重复的

js下拉框去掉重复的

2024-07-10 15:39| 来源: 网络整理| 查看: 265

                想用jquery代码实现这样的一个功能:有一个下拉框,当选择下拉框的时候,判断选择的值有没有被选择过,如果有则提示;代码如下:

          

$(function(){ var authTypes=new Array(); authTypes = $("#authTypes").val().split(','); $("#authType").on("change",function(){ console.log(authTypes) console.log("当前选择的" + $('#authType option:selected').val()) for(var val in authTypes){ console.log(val) if($('#authType option:selected').val() == authTypes[val]){ console.log(val+" selected:" + $('#authType option:selected').val()) alert("该分类已添加过"); return false; } } /* if(checkArray.indexOf($('#authType option:selected').val())


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3